package com.promote.hotspot.server.netty.dashboard;

import io.netty.channel.Channel;
import lombok.extern.java.Log;
import org.promote.hotspot.common.model.HotSpotMsg;
import org.promote.hotspot.common.model.MessageType;
import org.promote.hotspot.common.model.MsgBuilder;

/**
 * @author enping.jep
 * @date 2024/02/21 10:30
 **/
@Log
public class DashboardHolder {

    /**
     * 是否连上了dashboard
     */
    public static boolean hasConnected = false;
    /**
     * channel
     */
    public static Channel channel = null;

    public static void flushToDashboard(String message) {
        HotSpotMsg hotKeyMsg = new HotSpotMsg(MessageType.REQUEST_HOT_KEY);
        hotKeyMsg.setBody(message);
        log.info("dashboard push message:" + message);
        channel.writeAndFlush(MsgBuilder.buildByteBuf(hotKeyMsg));
    }
}
